<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点击</button>
    <script>
        function setDataHtml(){
            console.log(this);
        }
        setDataHtml();
        // 2.对象函数中this
        var star = {
            username:'刘德华',
            age:55,
            movis:function(){
                console.log(this);
                console.log('拍电影');
            }
        };
        star.movie();
        // 3.构造函数this
        function Mobile(brand,price){
            console.log(this);
            this.brand = brand;
            this.price = price;
        }
        var hw = new Mobile('华为',1000);
        // 4.定时器里面的this只想window
        // ()   =>  等价于function(){}
        function start(){
            console.log(this);

        }
        // setInterval(start,1000)
        // 点击事件
        document.querySelector('button').onclick=function(){
            // DOM对象<button>点击<button>
            console.log(this);
        }
    </script>
</body>
</html>